interface SquareConfig {
    color?: string;
    width?: number;
}

function createSquare(config: SquareConfig): { color: string; width: number } {
    let newSquare = {color: "white", width: 100};
    if (config.width) {
        newSquare.width = config.width * config.width;
    }
    return newSquare;
}

let mySquare = createSquare({color: "black", width: 100});

//函数类型的接口
interface searchFunc {
    (source: string, subString: string): boolean;
}

let mySearch = function (sourse: string, subString: string) {
    let result = sourse.search(subString);
    return result > -1;
}

//
interface ClockInterface {
    currentTime: Date;
}

class Clock implements ClockInterface {
    currentTime: Date;
    constructor(h: number, m: number) { }
}
